public class O18 {
    public ListNode deleteNode(ListNode head, int val) {
        if (head.val==val)
            return head.next;
        ListNode re = head;
        while (head.next!=null){
            if (head.next.val==val){
                head.next = head.next.next;
                return re;
            }
            head = head.next;
        }
        return re;
    }
}
